package com.augrain.demo.controller;

import com.augrain.demo.model.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * ModelAttribute测试
 *
 * @author biaoy
 * @date 2021/8/8
 */
@RestController
public class ModelAttributeController {

    @ModelAttribute
    public User modelUser() {
        User user = new User();
        user.setAge(10);
        user.setName("zhang san");
        return user;
    }

    @GetMapping("m1")
    public void test(@ModelAttribute("md") Map<String, Object> map) {
        System.out.println(map);
    }

    @GetMapping("m2")
    public void m2(User user) {
        System.out.println(user);
    }
}
